import { useContext } from 'react'
import { Input, Button, Upload } from 'antd'
import styles from './index.module.less'
import CheckAuthority from '@/components/CheckAuthority'
import { ResourceZoneContext } from '../../_context'
import IconSvg from '@/components/IconSvg'

export default () => {
  const { titleSearch, handleFileUpload, handleUpload } = useContext(ResourceZoneContext)

  return (
    <div className={styles.filterWrapper}>
      <div style={{ marginBottom: '24px' }}>
        <Input onPressEnter={titleSearch} style={{ width: '240px' }} placeholder='请输入标题' />
      </div>
      <CheckAuthority role={10}>
        <Upload
          className={styles.UploadWrapper}
          accept='.xlsx, .xls, .docx, .pdf'
          customRequest={({ file }) => handleFileUpload(file)}
          onChange={handleUpload}
          showUploadList={false} // 隐藏上传列表
        >
          <Button icon={<IconSvg name='addNew' style={{ marginRight: '8px' }} />}>新增文件</Button>
        </Upload>
      </CheckAuthority>
    </div>
  )
}
